﻿@{
    ViewBag.Title = "NewDoc";
}
@using wne.models
@model DocModel
<script src="/Scripts/Documents.js?1"> </script>


@using (Html.BeginForm("NewDoc", "Document", FormMethod.Post, new {id = "NewDocForm", onsubmit = "NewDocSubmit();"}))
{
    <div class="hero-unit row" style="margin: 10px 0 10px 0; padding: 10px 0 10px 10px;">
                            
        <div class="row-fluid">
                               
            <h2>Новый документ</h2>

        </div>

        <div class="row-fluid"> 
                                     

            <div class="span3"> 
                <div class="row-fluid">
                    <small>Введите название документа</small> 
                    @*@Html.HiddenFor(m => m.doc.Doc_Type, "Doc_Type")
                    @Html.HiddenFor(m => m.doc.Way_ID, "Way_ID")
                    @Html.TextBoxFor(m => m.doc.Doc_Name, "Doc_Name", new {placeholder = "Название документа", @class = "input-xlarge"})*@
                    <input type="hidden" name="Doc_Type" value="@Model.doc.Doc_Type"/>
                    <input type="hidden" name="Way_ID" value="@Model.doc.Way_ID"/>
                    <input type="text" placeholder = "Название документа" class = "input-xlarge" name="Doc_Name" value="@Model.doc.Doc_Name"/>
                </div>
                                      
                                      
            </div>
                               
            <div class="span2 offset1"> 
                                
                <div class="row-fluid">    
                    <small>Имя автора </small>
                    @{ string a = ViewBag.UserName; }
                    @Html.TextBox(a, a, new {disabled = "disabled", @class = "input-xlarge focused"})
                                 

                                  
                </div>                   
            </div>
                                   
        </div>
    </div>

    @*<div class="row-fluid">
        <div class="span6">
            <p><strong>Описание</strong></p>
           @Html.TextAreaFor(m => m.doc.) 
        </div>
    </div>*@


    <p> <strong>Список полей, предназначенных для выбранного документа</strong></p>
    <div class="row-fluid">
        @if (Model.fields != null)
        {
            int i = 0;
            foreach (DocField g in Model.fields)
            {
                if (g.type.Visible_Flag == "1")
                {
                    <div class="control-group">
                        <label class = "control-label" for="fields">@g.Field.Title</label>
                        @*@Html.LabelFor(m => m.fields[i].Field.Value, g.Field.Title, new {@class = "control-label"})*@
                        <div class ="controls">
                            @if (g.type.Editable_Falg == "1" && (g.type.Field_Type == 7 || g.type.Field_Type == 10))
                            {
                                <div class ="controls">
                                    <input type="file" name="fileUpload" id="upload_hidden" style="display: none;" onchange=" document.getElementById('upload_visible').value = this.value; " />
                                    <input type="text" readonly="1" id="upload_visible" onclick=" document.getElementById('upload_hidden').click(); " style="margin-bottom: 0;">
                                    <button class="btn" onclick=" document.getElementById('upload_hidden').click(); "><i class="icon-search"></i></button>    
                                </div>
                            }
                            else if (g.type.Editable_Falg == "1")
                            {
                                <input type="text" class = "input-xlarge" name="fields" value="@Model.fields[i].Field.Value"/>
                                @*@Html.TextBoxFor(m => m.fields[i].Field.Value)*@
                            }
                            else
                            {
                                <input type="text" disabled = "disabled" class = "input-xlarge" name="fields" value="@Model.fields[i].Field.Value"/>
                                @*@Html.TextBoxFor(m => m.fields[i].Field.Value, new {disabled = "disabled"})*@
                            }
                        </div> 
                    </div>

                }
                i++;
            }
        }
    </div>

    <label class="radio">
        <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
        Отправить
    </label>
    <label class="radio">
                <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" checked>
                Сохранить
            </label>
    
    <br/>
    <button type="submit" class="btn btn-primary">Готово</button>
    <button type="button" class="btn" onclick="location.href = '/Document/EditDoc'">Отменить</button>
}